/*
 * @(#)IHEConfigTestProducer.java
 * Date 2013-11-02
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.ihetest.inject;

import java.io.InputStream;

import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Produces;

import us.hornerscorners.lamppost.ihecommon.config.IHEConfig;

import us.hornerscorners.lamppost.ihecommon.inject.IHEConfigProducer;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-11-02
 * @author         Jim Horner
 */
@Alternative
public class IHEConfigTestProducer {

    /**
     * Method description
     *
     *
     *
     * @return
     */
    @Produces
    public IHEConfig produce() {

        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream is = cl.getResourceAsStream("config/META-INF/IHEConfig.yml");

        if (is == null) {

            throw new IllegalStateException("Missing config/META-INF/IHEConfig.yml");
        }

        return IHEConfigProducer.readConfig(is);
    }
}
